home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
os2
/
os2cop20.zip
/
OS2COPY2.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-04-06
|
20KB
|
580 lines
/*
┌───────────────────────────────────────────────────────────────────────┐
│ OS2Copy2.CMD v. 2.01 part 1 of 2. │
│ REXX script to copy OS/2 HPFS or FAT BootManager system, │
│ from one drive letter to another eg. from D: to E:, │
│ from FAT to FAT, HPFS to HPFS, part 2. │
│ │
│ Documentation is found in the file OS2COPY.DOC │
│ │
│ Copyright (C): John Ståhle │
│ 289A Buddinge Hovedgade │
│ DK-2880 Bagsværd │
│ Denmark, Europe │
│ Phone +45 44 98 66 18 │
│ │
│ Disclaimer, warning and what not: │
│ !! NO responsibility or any other obligation you can ever think of │
│ is assumed, honored or anything else. │
└───────────────────────────────────────────────────────────────────────┘
*/
/*───────────────────────────────────────────────────────────────────────*/
Call RxFuncAdd SysLoadFuncs, RexxUtil, SysLoadFuncs
CALL SysLoadFuncs
PARSE UPPER Arg all_args
HPFSSys = 'HPFS'
FATSys = 'FAT'
'@ECHO OFF'
'CLS'
CALL StartMelding
CALL HentParametre
IF (FromDrive==ToDrive) THEN DO
CALL FromSameAsTo
CALL HentParametre
IF (FromDrive==ToDrive) THEN DO
CALL FromSameAsTo
EXIT
END
CALL SysCls
END
ToSubDir = SUBSTR(FromDrive,1,1)
ToLetter = SUBSTR(ToDrive,1,1)
ToLocation = ToDrive'\'ToSubDir
FromDrive
CALL FindFiler
CALL GetYesNo
CALL GetXCopSw
CALL AskCreate
IF (JaNej \= YesLetter) THEN 'FDISK'
CALL SysCls
CALL Kopimeddelelse
IF (OK \= YesLetter) THEN DO
SAY
SAY "┌────────────────────────────────┐"
SAY "│ Let us give it one more chance │"
SAY "└────────────────────────────────┘"
SAY
OK = ' '
CALL Kopimeddelelse
IF (OK \= YesLetter) THEN DO
CALL CleanUp
EXIT
END
END
/* Here goes */
CALL DiskFormat
CALL CheckFreeBefore
CALL MakeDirs
CALL PerformXcopy
CALL CopyInitFilesToNewDrive
CALL CopyBinFiles
CALL CopyTextFiles
CALL LineOut(CInitList)
CALL EditInitFiles
CALL CopyInitFilesToInstall
CALL CopyTextFilesToInstall
CALL LineOut(CInitList)
DROP CInitList
CALL Slutmelding
CALL CleanUp
EXIT
/*───────────────────────────────────────────────────────────────────────*/
GetYesNo:
YesNo = ' '
DO WHILE (SubStr(YesNo,2,1) \= '/')
YesNo = LineIn(YesNoFile)
END
YesLetter = SubStr(YesNo,1,1)
NoLetter = SubStr(YesNo,3,1)
IF (YesLetter == ' ') THEN YesLetter = 'Y'
IF (NoLetter == ' ') THEN NoLetter = 'N'
CALL LineOut(YesNoFile)
RETURN
/*.......................................................................*/
GetXCopSw:
XCopSw = ' '
DO WHILE (SubStr(XCopSw,2,1) \= '/')
XCopSw = LineIn(XCopSwFile)
END
IF (XCopSw == ' ') THEN XCopSw = ' /E /H /T /R /V'
CALL LineOut(XCopSwFile)
RETURN
/*.......................................................................*/
FindFiler:
InitEditFil = 'InitEdit.EXE'
InitEditExe = SysSearchPath('PATH',InitEditFil)
IF (InitEditExe=='') then DO
NoFileName = InitEditFil
CALL FileNotThere
EXIT
END
InitEditList = 'InitEdit.Lst'
CInitList = SysSearchPath('PATH',InitEditList)
IF (CInitList=='') then DO
NoFileName = InitEditList
CALL FileNotThere
EXIT
END
InitEditLis2 = SubStr(CInitList,1,LastPos('.',CInitList))'LS2'
'COPY 'CInitList' 'InitEditLis2
CInitList = InitEditLis2
CInitLis2 = SysSearchPath('PATH',InitEditList)
YesNoFil = 'YesNo.LNG'
YesNoFile = SysSearchPath('PATH',YesNoFil)
IF (YesNoFile=='') then DO
NoFileName = YesNoFil
CALL FileNotThere
EXIT
END
XCopSwFil = 'XCopy.Sw'
XCopSwFile = SysSearchPath('PATH',XCopSwFil)
RETURN
/*.......................................................................*/
HentParametre:
ArgNo = 1
IF (word(all_args,ArgNo)=='') THEN DO
SAY 'OS2Copy <FromDrive>: <ToDrive>:'
SAY
SAY ' <FromDrive>: hard drive with OS/2 installed.'
SAY
SAY ' <ToDrive>: hard drive OS/2 is to be copied to,'
SAY ' REQUIRED in this script.'
SAY
END
CALL HentFraParametre
CALL HentTilParametre
RETURN
/*.......................................................................*/
HentFraParametre:
ArgNo = 1
k = SysCurPos()
FromDrive = word(all_args,ArgNo)
IF (FromDrive=='') THEN FraDisk = SUBSTR(DIRECTORY(),1,2)
DO WHILE (FromDrive=='')
CALL SysCurPos word(k,1), 0
SAY 'Hard drive to copy OS/2 system FROM (X:) ?'
CALL SysCurPos word(k,1), 48
PULL FromDrive
END
IF (SUBSTR(FromDrive,2,1) \= ':') THEN FromDrive = FromDrive':'
RETURN
/*.......................................................................*/
HentTilParametre:
ArgNo = ArgNo + 1
ToDrive = word(all_args,ArgNo)
k=SysCurPos()
DO WHILE (ToDrive=='')
CALL SysCurPos word(k,1), 0
SAY 'Hard drive to copy your OS/2 system TO (X:) ?'
PULL ToDrive
END
IF (SUBSTR(ToDrive,2,1) \= ':') THEN ToDrive = ToDrive':'
RETURN
/*.......................................................................*/
DiskFormat:
'FDISK /Query |'RXQueue
FilSysInfo.0 = QUEUED()
DO i = 1 TO FilSysInfo.0
PARSE PULL FilSysInfo.i
IF (SubStr(FilSysInfo.i,19,2)==FromDrive) THEN DO
IF (SubStr(FilSysInfo.i,30,2)=='07') THEN FromFilSys = HPFSSys
IF (SubStr(FilSysInfo.i,30,2)=='06') THEN FromFilSys = FATSys
END
END
'CLS'
SAY '┌─────────────────────────────────────────────────────────────────────────┐'
SAY '│ If, for some reason, the format does not work: Press Ctrl C to end │'
IF (FromFilSys == HPFSSys) THEN DO
SAY "│ and perform format "ToDrive" /FS:"FromFilSys" 'by hand', giving NO label │"
END
ELSE DO
SAY "│ and perform format "ToDrive" /FS:"FromFilSys" 'by hand', giving NO label │"
END
SAY '│ │'
SAY '│ and restart the computer afterwards. │'
SAY '└─────────────────────────────────────────────────────────────────────────┘'
SAY '┌─────────────────────────────────────────────────────────────────────────┐'
SAY '│ │'
SAY '│ If you answer > 'YesLetter' < partition 'ToDrive' will become formatted !!! │'
SAY '│ │'
SAY '│ !!! This means, that ALL data on 'ToDrive' is lost !!! │'
SAY '│ │'
SAY '└─────────────────────────────────────────────────────────────────────────┘'
SAY '┌─────────────────────────────────────────────────────────────────────────┐'
SAY '│ │'
k = SysCurPos()
SAY '│ Are you sure you want 'ToDrive' to become formatted │'
SAY '│ │'
SAY '└─────────────────────────────────────────────────────────────────────────┘'
JaNej = 'x'
DO WHILE ((JaNej \= YesLetter) & (JaNej \= NoLetter))
CALL SysCurPos word(k,1),52
SAY '('YesNo') ?'
CALL SysCurPos word(k,1),61
PULL JaNej
END
IF (JaNej \= YesLetter) THEN DO
CALL CleanUp
EXIT
END
SAY
SAY
'Echo 'JaNej'|Format 'ToDrive' /FS:'FromFilSys' /V:'ToLetter'OS2'FromFilSys
RETURN
/*.......................................................................*/
CheckFreeBefore:
CALL CheckFree
IF (ToFree < FromUsed) THEN DO
CALL SysCls
SAY
SAY 'Drive 'FromDrive' contains 'FORMAT(FromUsed,8,0)' KB files etc.'
SAY 'Drive 'ToDrive' has room for only 'FORMAT(ToFree,8,0)' KB'
SAY 'There is NOT room enough for a copy of 'FromDrive' on 'ToDrive
SAY
SAY 'Press CTRL C to stop or'
'PAUSE'
END
RETURN
/*.......................................................................*/
CheckFreeAfter:
SwapSize = 0
/*
SwapFile = Fromdrive'\OS2\SYSTEM\Swapper.Dat'
RC = SysFileTree(SwapFile,'Swap.','F')
IF (Swap.0 > 0) THEN DO
SwapSize = WORD(Swap.1,3)
END
ELSE DO
SwapSize = 4096 * 1024
END
*/
InitSize = 0
FromInis = FromDrive'\OS2\*.INI'
RC = SysFileTree(FromInis,'InitFiles.','F')
IF (InitFiles.0 > 0) THEN DO i = 1 TO InitFiles.0
InitSize = InitSize + WORD(InitFiles.i,3)
END
ELSE DO
InitSize = 1000
END
InitSize = (InitSize * 1.2 + SwapSize) /1024
CALL CheckFree
IF (ToFree < InitSize) THEN DO
CALL SysCls
SAY
SAY 'Drive 'FromDrive' contains 'FORMAT(InitSize,8,0)' KB init files'
SAY 'Drive 'ToDrive' has room for only 'FORMAT(ToFree,8,0)' KB'
SAY 'There is NOT room enough for a copy of 'FromDrive' on 'ToDrive
SAY
SAY '┌─────────────────┐'
SAY '│ Aborting │'
SAY '└─────────────────┘'
CALL CleanUp
EXIT
END
RETURN
/*.......................................................................*/
CheckFree:
FromInfo = SysDriveInfo(FromDrive)
FromTotal = SUBWORD(FromInfo,3,1)/1024
FromFree = SUBWORD(FromInfo,2,1)/1024
FromUsed = FromTotal - FromFree
ToInfo = SysDriveInfo(ToDrive)
ToFree = SUBWORD(ToInfo,2,1)/1024
RETURN
/*.......................................................................*/
PerformXcopy:
'XCOPY 'FromDrive'\*.* 'ToDrive'\ 'XcopSw' /S /E'
RETURN
/*.......................................................................*/
CopyInitFilesToNewDrive:
CALL SysCls
SAY '┌─────────────────────────────────────────────────────────────┐'
SAY '│ │'
SAY '│ Now is the time to remove superfluous files on 'ToDrive' │'
SAY '│ using a different thread │'
SAY '│ │'
SAY '│ Now is also the time to shut down ALL OTHER processes │'
SAY '│ │'
SAY '│ Do NOT remove the 'ToLocation' subdirectory ! │'
SAY '│ │'
SAY '└─────────────────────────────────────────────────────────────┘'
'PAUSE'
CALL CheckFreeAfter
CALL MakeDirs
CALL InitCopyMelding
InitFil = LineIn(CInitList,1,1)
DO WHILE InitFil \= '>INIT_FILES'
InitFil = LineIn(CInitList)
END
InitFil = LineIn(CInitList)
DO WHILE ((InitFil \= '>BIN_FILES') & (LEFT(InitFil,1)=='\'))
IndIni = FromDrive'\OS2'InitFil
UdIni = ToLocation||InitFil
SAY 'Working on 'IndIni
CALL PerformInitCopy
InitFil = LineIn(CInitList)
END
RETURN
/* .....................................................................*/
/* The basic concept of this is from the REXX online-docs SysIni sample. */
PerformInitCopy:
IF (SysIni(IndIni,'All:','Progs.') =='') THEN DO i = 1 to Progs.0
IF (SysIni(IndIni,Progs.i,'All:','Keys.') =='') THEN DO j = 1 to Keys.0
Val = SysIni(IndIni, Progs.i, Keys.j)
IF (Val\='') THEN DO
IF (SysIni(UdIni,Progs.i,Keys.j,Val)=='ERROR:') THEN DO
SAY 'Failure setting 'Progs.i' : 'Keys.j
END
END
END
END
RETURN
/* .....................................................................*/
CopyInitFilesToInstall:
InitFil = LineIn(CInitList,1,1)
DO WHILE InitFil \= '>INIT_FILES'
InitFil = LineIn(CInitList)
END
DO WHILE (InitFil \= '>BIN_FILES')
InitFil = LineIn(CInitList)
DO WHILE (substr(InitFil,1,1)=='\')
'XCOPY 'ToDrive'\OS2'InitFil ToDrive'\OS2\INSTALL 'XCopSw
InitFil = LineIn(CInitList)
END
END
RETURN
/*.......................................................................*/
CopyBinFiles:
DO WHILE (BinFil \= '>TXT_FILES')
BinFil = LineIn(CInitList)
DO WHILE (substr(BinFil,1,1)=='\')
'XCOPY 'FromDrive'\OS2'BinFil ToLocation' 'XCopSw
'XCOPY 'FromDrive'\OS2'BinFil ToDrive'\OS2 'XCopSw
BinFil = LineIn(CInitList)
END
END
RETURN
/*.......................................................................*/
CopyTextFiles:
DO WHILE (TxtFil \= '>>>THE_END')
TxtFil = LineIn(CInitList)
DO WHILE (substr(TxtFil,1,1)=='\')
'XCOPY 'FromDrive||TxtFil' 'ToLocation' 'XCopSw
TxtFil = LineIn(CInitList)
END
END
RETURN
/*.......................................................................*/
CopyTextFilesToInstall:
DO WHILE (TxtFil \= '>>>THE_END')
TxtFil = LineIn(CInitList)
DO WHILE (substr(TxtFil,1,1)=='\')
'XCOPY 'ToDrive||TxtFil' 'ToDrive'\OS2\INSTALL 'XCopSw
TxtFil = LineIn(CInitList)
END
END
RETURN
/*.......................................................................*/
EditInitFiles:
InitEditExe' 'FromDrive' 'ToDrive' 'CInitLis2' 'InitEditExe
RETURN
/*.......................................................................*/
CleanUp:
'Del 'Fromdrive'\Startup.CMD'
'Copy 'Fromdrive'\StartUp.@#@ 'Fromdrive'\Startup.Cmd'
'Del 'Fromdrive'\Startup.@#@'
'Del 'Todrive'\Startup.CMD'
'Copy 'ToDrive'\StartUp.@#@ 'ToDrive'\Startup.Cmd'
'Del 'Todrive'\Startup.@#@'
'Del 'Fromdrive'\OS2Copy.INI'
'Del 'Fromdrive'\OS2Copy.ASC'
'Del 'Todrive'\OS2Copy.INI'
'Del 'Todrive'\OS2Copy.ASC'
RETURN
/*.......................................................................*/
StartMelding:
SAY '┌────────────────────────────────────────────────────────────────────────┐'
SAY '│ │'
SAY '│ OS2Copy2 v.2.01 Copyright (c) 1993.01.19: John Ståhle │'
SAY '│ This OS2Copy script is placed in the Public Domain │'
SAY '│ │'
SAY '└────────────────────────────────────────────────────────────────────────┘'
SAY '┌────────────────────────────────────────────────────────────────────────┐'
SAY '│ │'
SAY '│ You will get messages telling that OS2.INI, OS2SYS.INI and SWAPPER.DAT │'
SAY "│ can NOT be copied (this is during the XCOPY part) - don't worry, │"
SAY '│ these files will be copied and edited later in the process. │'
SAY '│ │'
SAY '└────────────────────────────────────────────────────────────────────────┘'
'PAUSE'
RETURN
/*.......................................................................*/
InitCopyMelding:
SAY '┌───────────────────────────────────────────────────────────────────────┐'
SAY '│ │'
SAY '│ Copying .INI files by querying the keys in progress. │'
SAY '│ │'
SAY '└───────────────────────────────────────────────────────────────────────┘'
RETURN
/*.......................................................................*/
FileNotThere:
SAY '┌───────────────────────────────────────────────────────────────────┐'
SAY '│' NoFileName' was >> NOT << found in your path'
SAY '│' NoFileName' is crucial for the success of this procedure'
SAY '│ !!! Path to 'NoFileName' must be included in your Config.Sys !!!'
SAY '│ !!! Path to 'NoFileName' must be included in your Autoexec.Bat !!!'
SAY '└───────────────────────────────────────────────────────────────────┘'
RETURN
/*.......................................................................*/
FromSameAsTo:
SAY '┌─────────────────────────────────────────────────────────────────────────┐'
SAY '│ │'
SAY '│ FromDrive ('FromDrive') is the same as ToDrive ('ToDrive') NO GO! │'
SAY '│ │'
SAY '└─────────────────────────────────────────────────────────────────────────┘'
'PAUSE'
CALL SysCls
RETURN
/*.......................................................................*/
Kopimeddelelse:
SAY '┌───────────────────────────────────────────────────────────────────────┐'
SAY '│ │'
SAY '│ Copying OS/2 FROM 'FromDrive' │'
SAY '│ Copying OS/2 TO 'ToDrive' │'
SAY '│ │'
k = SysCurPos()
SAY '│ OK ('YesNo') ? │'
SAY '└───────────────────────────────────────────────────────────────────────┘'
p = SysCurPos()
DO WHILE ((OK \= YesLetter) & (OK \= NoLetter))
CALL SysCurPos word(k,1),14
PULL OK
END
CALL SysCurPos word(p,1),0
RETURN
/*.......................................................................*/
AskCreate:
SAY '┌───────────────────────────────────────────────────────────────────────────┐'
SAY '│ │'
k = SysCurPos()
SAY '│ Did you remember to create a partition and insert it in BootManager │'
SAY '│ │'
SAY '└───────────────────────────────────────────────────────────────────────────┘'
p = SysCurPos()
DO WHILE ((JaNej \= YesLetter) & (JaNej \= NoLetter))
CALL SysCurPos word(k,1),69
SAY '('YesNo')?'
CALL SysCurPos word(k,1),75
PULL JaNej
END
CALL SysCurPos word(p,1),0
RETURN
/* .....................................................................*/
Slutmelding:
SAY
SAY 'A backup of original files is left in subdirectory 'ToLocation
SAY
SAY 'SYSxxxx: The system cannot find the file specified.'
SAY ' is >>> OK <<<'
SAY
SAY 'This just tells that originally you did not have no STARTUP.CMD'
SAY
RETURN
/*.......................................................................*/
MakeDirs:
SAY
SAY 'SYSxxxx: A subdirectory or file 'ToLocation' already exists.'
SAY 'SYSxxxx: A subdirectory or file 'ToDrive'\OS2 already exists.'
SAY
SAY ' are >>> OK <<<'
SAY
'MD 'ToLocation
'MD 'ToDrive'\OS2'
RETURN
/*───────────────────────────────────────────────────────────────────────*/